<template>
	<view class="">
		<view class="xian">

		</view>
		<!-- 下面的列表 -->
		<view class="booksList p-20">
			<view v-for="(item,index) in list" :key="index" @click="booksFn(item)" class="itemBooks f f-a-c m-b-30">
				<div class="booksImg m-r-20 b-r-20">
					<image :src="item.cover" class="imgs" mode=""></image>

				</div>
				<view class="booksRight">
					<view class="tit f f-a-c m-t-10 m-b-10">
						<view class="oneNights m-r-10">
							{{item.name}}
						</view>
						<view class="children">
							{{item.category.name}}
						</view>
					</view>
					<view class="age">
						{{item.author}}著 {{item.press}}
					</view>
					<view class="age m-t-10">
						适读年龄：{{item.age_limit.name}}
					</view>
					<view class="botColor f f-a-c m-t-10">
						<view v-for="(ite,ind) in item.tags" :key="ind" class="lef m-r-10">
							{{ite.name}}
						</view>
						<!-- 	<view class="lef">
							启蒙教育
						</view> -->
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				age_limit_id: '',
				q: '',
				category_id: '',
				page: 1,
				list: [],
				category_id: '',
				age_limit_id: '',
				is_newest: '',
				is_recommend: ''
			}
		},
		onLoad(options) {
			this.page = 1
			this.list = []
			this.q = options.q || ''
			this.category_id = options.category_id || ''
			this.age_limit_id = options.age_limit_id || ''
			this.is_recommend = options.is_recommend || ''
			this.is_newest = options.is_newest || ''
			this.initList()
		},
		methods: {
			async initList() {
				let n = await this.$api.SelectionList({
					page: this.page,
					q: this.q,
					category_id: this.category_id,
					age_limit_id: this.age_limit_id,
					is_recommend: this.is_recommend,
					is_newest: this.is_newest
				})
				if (this.page == 1) {
					this.list = n.data.data
				} else {
					this.list = [...this.list, ...n.data.data]
				}
			},
			//跳转到详情页 
			booksFn(item) {
				uni.navigateTo({
					url: '/pages/index/DetailsPage?id=' + item.id
				})
			}
		},
		onReachBottom() {
			this.page++
			this.initList()
			console.log('123456')
		}
	}
</script>

<style lang="scss" scoped>
	.booksRight {
		width: 80%;
	}

	.xian {
		position: fixed;
		top: 0;
		left: 0;
		z-index: 99;
		width: 100%;
		height: 2rpx;
		background: #dcdbdb;
	}

	.booksImg {
		width: 154rpx;
		height: 196rpx;

		.imgs {
			width: 100%;
			height: 100%;
			object-fit: cover;
		}
	}

	.lef {
		width: 118rpx;
		height: 40rpx;
		line-height: 40rpx;
		background: #fff9e8;
		border-radius: 8rpx;
		font-size: 28rpx;
		font-family: PingFang SC, PingFang SC-Regular;
		font-weight: 400;
		text-align: center;
		color: #ecbf2f;
	}

	.age {
		font-size: 30rpx;
		font-family: PingFang SC, PingFang SC-Regular;
		font-weight: 400;
		text-align: left;
		color: #999999;
	}

	.itemImg {
		width: 100%;
		height: 196rpx;
		border-radius: 20rpx;
	}

	.children {
		width: 118rpx;
		height: 40rpx;
		line-height: 40rpx;
		background: #edf8f6;
		border-radius: 8rpx;
		font-size: 28rpx;
		font-family: PingFang SC, PingFang SC-Regular;
		font-weight: 400;
		text-align: center;
		color: #009d85;
	}

	.oneNights {
		width: 70%;
		font-size: 32rpx;
		font-family: PingFang SC, PingFang SC-Bold;
		font-weight: 700;
		text-align: left;
		color: #1a1a1a;
	}
</style>